/*
	Copyright (C) 2009 Salil Bhagurkar
	
	This file is part of ViSE
	
	ViSE is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	ViSE is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with ViSE.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <shared.h>

static struct node_fs *usr= NULL, *msg = NULL, *notifier = NULL;



static char dbuf[PRINTF_BUF_LEN];
int printk(const char *fmt, ...)
{
	if(!msg) {
		va_list args;
		int ret_val;
		va_start(args, fmt);
		ret_val = vsnprintf(dbuf,PRINTF_BUF_LEN,fmt,args);
		b8000_write(dbuf);
		va_end(args);
		return ret_val;
	} else {
		va_list args;
		int ret_val;
		va_start(args, fmt);
		ret_val = vsnprintf(dbuf,PRINTF_BUF_LEN,fmt,args);
		msg->write(msg, dbuf, 0, 0);
		va_end(args);
		return ret_val;
	}
}

int init_printk()
{
	msg = fs_get("/usr/msg");
	return 0;
}
